FROM alpine:3.19

LABEL authors="sugar"
EXPOSE 5000

# 更新系统包并安装 Python3.8 和 pip，使用国内源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
    apk update && \
    apk add --no-cache python3 py3-pip

# 设置环境变量
ENV PATH="/usr/bin:${PATH}"

# 创建并激活虚拟环境
RUN python3 -m venv /app/venv
ENV PATH="/app/venv/bin:${PATH}"

WORKDIR /app

COPY . /app

# 使用国内 pip 源加速依赖包安装
RUN pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple && \
    pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

CMD ["python", "./main.py"]